<!DOCTYPE html>

<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>

        <script type="text/javascript">
            ( function(){
                let url = "/app/js";
                // 创建可以发送请求接受响应的对象
                let $http = new XMLHttpRequest();
                console.log( $http.readyState );
                /*
                $http.addEventListener( 'readystatechange' , function(){
                    console.log( $http.readyState );
                    if( $http.readyState == $http.DONE ) {
                        console.log( $http.responseText );
                    }
                });
                */
                $http.addEventListener( 'load' , function(){
                    console.log( $http === this );
                    if( this.status === 200 ) {
                        console.log(this.responseText);
                    } else {
                        console.log(this.statusText);
                    }
                });
                // 打开连接
                $http.open( 'GET' , url );
                $http.send();
            } )();
        </script>

    </head>
    <body>

    </body>
</html>